import { type IBaseData } from '../types'
/**
 * 数据管理系统
 */
export class DataManager {
  // 原始数据
  private readonly originalData: IBaseData[]
  // 排序数据
  private readonly sortedData: IBaseData[]
  // 筛选数据
  private readonly filteredData: IBaseData[]

  constructor (data: IBaseData[]) {
    this.originalData = data
    this.sortedData = [...data]
    this.filteredData = [...data]
  }

  sort (comparator: (a: IBaseData, b: IBaseData) => number): void {
    this.sortedData.sort(comparator)
    this.updateFilteredData()
  }

  filter (predicate: (item: IBaseData) => boolean): void {
    // this.filterPredicate = predicate
    this.updateFilteredData()
  }

  private updateFilteredData (): void {
    // this.filteredData = this.sortedData.filter(this.filterPredicate)
  }
}
